﻿using System;
using System.Web.Services;
using DAL;
using NLog;

public partial class Admin_Category : ParentPage
{

    private static Logger _logger = LogManager.GetCurrentClassLogger();

    #region Pageload
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ManageCategory objDALCategory = new ManageCategory();
            rptManageCategory.DataSource = objDALCategory.GetAllCategory();
            rptManageCategory.DataBind();
        }
        catch (Exception ex)
        {
            _logger.Error("Admin_Category:::Page_Load:::" + ex.Message);
        }
    }
    #endregion

    #region Events
    protected void lbtnRefreshGV_Click(object sender, EventArgs e)
    {
        try
        {
        }
        catch (Exception ex)
        {
            //_logger.Error("Admin_Category:::lbtnRefreshGV_Click:::" + ex.Message);
        }
    }

    #endregion

    #region Methods
    /// <summary>
    /// Convert Category Status from Number to text
    /// </summary>
    /// <param name="sCategoryStatus">set Category Status "string value"</param>
    /// <returns>return Category status</returns>
    protected string CheckCategoryStatus(string sCategoryStatus)
    {
        try
        {
            switch (sCategoryStatus)
            {
                case "1":
                    return "Active";
                case "0":
                    return "Pending";
                default:
                    return "Unknown";
            }
        }
        catch (Exception)
        {
            return "Unknown";
        }
    }
    #endregion

    #region WebMethods

    [WebMethod]
    public static string DeleteCategoryInfo(string sCategoryID)
    {
        try
        {
            ManageCategory objDALCategory = new ManageCategory();
            int nReturnValue = objDALCategory.DeleteCategory(sCategoryID);
            if (nReturnValue == 1)
                return "true";
            else
                return "false";
        }
        catch (Exception ex)
        {
            _logger.Error("Admin_Category:::DeleteCategoryInfo:::" + ex.Message);
            return "false";
        }
    }
    #endregion
}